<?php

global $confirmType;
global $actionType;
global $organizationType;
global $reportType;
$startdate=isset($_POST['fromYear'])?$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate']:'2000-01-01';
				$enddate=isset($_POST['toYear'])?$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate']:date('Y-m-d');
	if(isset($_POST['fromYear'])){
		$year1=$_POST['fromYear'];
		$month1=$_POST['fromMonth'];
		$date1=$_POST['fromDate'];
		$year2=$_POST['toYear'];
		$month2=$_POST['toMonth'];
		$date2=$_POST['toDate'];
		
	}else{
		$year1='2000';
		$month1='01';
		$date1='01';
		$year2=date('Y');
		$month2=date('m');
		$date2=date('d');
	}
	
	if(isset($_POST['targetYear'])){
		$year3=$_POST['targetYear'];
		$month3=$_POST['targetMonth'];		
	}else{
		$year3=date('Y');
		$month3=date('m');
	}
	$year= date('Y');
	$month= date('m');
	$date= date('d');
	
//return;
?>
	<div class="block">

	<div class="invertedshiftdown">
		
		<ul>
			<li class="current"><a href="?page=accounting_sell_record">销售统计</a></li>
			<li><a href="?page=accounting_distributing">物流统计</a></li>
			<li><a href="?page=accounting_inventory">库存统计</a></li>
			<li><a href="?page=accounting_report">财政报表</a></li>
 		</ul>




		<form id="myform">
			<input type="text" class="textinput" /> <input class="submit" type="submit" value="搜索" />
		</form>
	</div>
	<br style="clear: both;" />
	
<div id= 'content'>

		<h2>菲雪洛琳》销售统计显示》<?php echo $reportType[$option];?></h2>
		
		<h4>选择报告范围</h4>
			 <form action="" method="post">
			 	<div id="monthSelect"style="clear:both; display:none;">
             	            <div class="element">

             <div class="element">

				 </div>
				 </div>
				  <li>
		
				<span>
					
					
					
				<select name="targetYear">
					<?php
					for($i = 2009; $i <= 2020; $i++){
						if($year3==$i){
						 echo "<option value='$i' selected>$i</option>";
						}else{
						 echo "<option value='$i'>$i</option>";		
							
						}
					}
					?>
				</select>
				 <label for="Field103">年</label>
				</span>
				<span class="symbol">/</span>
				<span>
				<select name="targetMonth">
					<?php
					for($i = 1; $i <= 12; $i++){
						if($i<10){
					   		$i="0".$i;
						}
					 if($month3==$i){
						 echo "<option value='$i' selected>$i</option>";
						}else{
						 echo "<option value='$i'>$i</option>";		
						}
					}
					?>
				</select><label for="Field103-1">月</label>
				</span> 
				</li>
			</div>
				   
				   
				   
				   
			 	<div id="dateSelect"style="clear:both;display:none;">
             	            <div class="element">
				 </div>
				  <li>
				<label>
				从
				</label>
				<span>
					
					
					
				<select name="fromYear">
					<?php
					for($i = 2009; $i <= 2020; $i++){
						if($year1==$i){
						 echo "<option value='$i' selected>$i</option>";
						}else{
						 echo "<option value='$i'>$i</option>";		
							
						}
					}
					?>
				</select>
				 <label for="Field103">年</label>
				</span>
				<span class="symbol">/</span>
				<span>
				<select name="fromMonth">
					<?php
					for($i = 1; $i <= 12; $i++){
						if($i<10){
					   		$i="0".$i;
						}
					 if($month1==$i){
						 echo "<option value='$i' selected>$i</option>";
						}else{
						 echo "<option value='$i'>$i</option>";		
						}
					}
					?>
				</select><label for="Field103-1">月</label>
				</span> 
				<span class="symbol">/</span>
				<span>
				<select name="fromDate">
					<?php
				   for($i = 1; $i <= 31; $i++){
				   	if($i<10){
					   		$i="0".$i;
						}
					   if($date1==$i){
						 echo "<option value='$i' selected>$i</option>";
						}else{
						 echo "<option value='$i'>$i</option>";		
						}
					}
					?>
				</select>
				<label for="Field103-2">日</label>
				</span>
				
				
				
				</li>
				
				  <li>
				<label>
				到
				</label>
				<span>
					
				
				<select name="toYear">
					<?php
					for($i = 2009; $i <= 2020; $i++){
						if($year2==$i){
						 echo "<option value='$i' selected>$i</option>";
						}else{
						 echo "<option value='$i'>$i</option>";		
							
						}
					}
					?>
				</select>
				 <label for="Field103">年</label>
				</span>
				<span class="symbol">/</span>
				<span>
				<select name="toMonth">
					<?php
					for($i = 1; $i <= 12; $i++){
						if($i<10){
					   		$i="0".$i;
						}
					 if($month2==$i){
						 echo "<option value='$i' selected>$i</option>";
						}else{
						 echo "<option value='$i'>$i</option>";		
							
						}
					}
					?>
				</select><label for="Field103-1">月</label>
				</span> 
				<span class="symbol">/</span>
				<span>
				<select name="toDate">
					<?php
					for($i = 1; $i <= 31; $i++){
						if($i<10){
					   		$i="0".$i;
						}
					   if($date2==$i){
					   
						 echo "<option value='$i' selected>$i</option>";
							
						}else{
						
						 echo "<option value='$i'>$i</option>";		
						}
					}
					?>
				</select>
				<label for="Field103-2">日</label>
				</span>
				
				
				
				</li>
				   </div>
				   <h4>选择报告种类</h4>
			<select id="option" name='option' onchange="optionChange()">
				<?php
				foreach($reportType as $key=>$type){
		           echo "<option value='$key'>$type</option>";
				}
				?>
			</select>
			<input class="submit" type="submit" value="搜索" />
		</form>
		<div class="isa_info">
		<h4><?php echo $message ?></h4><?php echo $condition ?>
	</div>
<?php
 if($option=='_s_report_daterange_by_date'){
?>
		<script type="text/javascript" src="js/jsapi.js"></script>
	<script type="text/javascript">

    google.load('visualization', '1', {'packages': ['annotatedtimeline'], 'language': 'zh'});
    function drawVisualization() {
      var data = new google.visualization.DataTable();
      <?php
      echo  "data.addColumn('date', 'Date');";
      echo  "data.addColumn('number', '退款额');\n";     
      echo  "data.addColumn('number', '营销额');\n";
	  echo "data.addRows([";
	  $result="";
	  while($row = mysql_fetch_array($lineCurve))
      {
   	     $time=$row['sale_date'];
   	      	
			$date1=date('Y,n,j', strtotime($time." -1 month"));
			
			 $return_amount=$row['return_amount'];
			 $sell_amount=$row['sell_amount'];
   	      	$result.=" [new Date($date1), $return_amount,$sell_amount],";
     }
	  if($result!=""){
		 $result=substr($result,0,-1);
		}
	  echo $result."]);";
	  //echo "]);";
      ?>
      
    
      var annotatedtimeline = new google.visualization.AnnotatedTimeLine(
          document.getElementById('visualization'));
     annotatedtimeline.draw(data, {'displayAnnotations': true});
    }
    
    google.setOnLoadCallback(drawVisualization);
  </script>

    <div id="visualization" style="width: 1000px; height: 650px;"></div>


	
		
<?php
   			}else if($option=='_s_report_daterange_by_month'){
				
?>
		<script type="text/javascript" src="js/jsapi.js"></script>
	<script type="text/javascript">

    google.load('visualization', '1', {packages: ['annotatedtimeline'], 'language': 'zh'});
    function drawVisualization() {
      var data = new google.visualization.DataTable();
      <?php
      echo  "data.addColumn('date', 'Date');";
      echo  "data.addColumn('number', '退款额');\n";     
      echo  "data.addColumn('number', '营销额');\n";
	  echo "data.addRows([";
	  $result="";
	  while($row = mysql_fetch_array($lineCurve))
      {
   	     $timeMonth=$row['sale_month'];
		 $timeYear=$row['sale_year'];
			$date1=date('Y,n,j', strtotime($timeYear."-".$timeMonth."-15 -1 month"));
			$return_amount=$row['return_amount'];
			$sell_amount=$row['sell_amount'];
   	      	$result.=" [new Date($date1), $return_amount,$sell_amount],";
     }
	  if($result!=""){
		 $result=substr($result,0,-1);
		}
	  echo $result."]);";
	  //echo "]);";
      ?>
      
    
      var annotatedtimeline = new google.visualization.AnnotatedTimeLine(
          document.getElementById('visualization'));
     annotatedtimeline.draw(data, {'displayAnnotations': true});
    }
    
    google.setOnLoadCallback(drawVisualization);
  </script>

    <div id="visualization" style="width: 1000px; height: 650px;"></div>
<?php
   			}else if($option=='_s_report_daterange_by_org'||$option=='_s_report_daterange_by_productcode'||$option=='_s_report_daterange_by_scancode'){
   				echo $table;
	?>	
        

<?php
   			}else if($option=='_s_report_daterange_by_date'){
				
?>
<?php
   			}else if($option=='_s_report_daterange_by_date'){
				
?>
<?php
   			}else if($option=='_s_report_daterange_by_date'){
				
?>
<?php
   			}else if($option=='_s_report_daterange_by_date'){
				
?>
<?php
   			}else{
				echo $table;
?>
<?php
   			}
				
?>

	
	
	<script type="text/javascript">
	//jQuery("#option").css("border","3px solid red");
	jQuery("#option").val('<?php echo $option?>');
    
    function update(){
    	switch(jQuery("#option option:selected").val())
		{
		case '_s_report_daterange_by_date':
		case '_s_report_daterange_by_month':
		case '_s_report_daterange_by_org':
		case '_s_report_daterange_by_productcode':
		case '_s_report_daterange_by_scancode':
		case '_detail_report':
			jQuery('#monthSelect').hide();
			jQuery('#dateSelect').show();

		  break;
		case '_s_report_monthyear_by_scancode':
		case '_s_report_monthyear_by_org':
		case '_s_report_monthyear_by_productcode':
			jQuery('#monthSelect').show();
			jQuery('#dateSelect').hide();
		  break;
		default:
		break;
		}
    }

    function optionChange(){
    	update();
      // alert(jQuery("#option option:selected").val());
    	
    }
    update();
	</script>

   
<div class="clear"></div>
	</div>